package services;

import domain.entities.DoctorDegreeDAO;
import domain.entities.GlobalCommitment;
import domain.entities.GlobalCommitmentDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: vgonzalez
 * Date: 02/11/12
 * Time: 12:35
 * To change this template use File | Settings | File Templates.
 */
@Service
public class GlobalCommitmentService {

    private GlobalCommitmentDAO globalCommitmentDAO;

    public GlobalCommitmentService() {
    }

    @Autowired
    public GlobalCommitmentService(GlobalCommitmentDAO globalCommitmentDAO) {
        this.globalCommitmentDAO = globalCommitmentDAO;
    }

    public GlobalCommitment findByProtocoloId(String id) {
        List<GlobalCommitment> result = globalCommitmentDAO.findByProtocoloId(id);
        if (result.isEmpty())
            return null;
        else return result.get(0);
    }

    public GlobalCommitment findById(Integer id) {
        return globalCommitmentDAO.findById(id);
    }


    public void save(GlobalCommitment globalCommitment) {
        globalCommitmentDAO.attachDirty(globalCommitment);
    }
}